package cn.bugstack.mybatis.session;

import cn.bugstack.mybatis.builder.xml.XmlConfigBuilder;
import cn.bugstack.mybatis.session.defaults.DefaultSqlSessionFactory;

import java.io.Reader;
/**
 * SqlSessionFactoryBuilder是myBatis 的入口
 * 通过解析XML文件 将信息传入configuration
 * configuration会被传递到各个逻辑中使用
 * */
public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(Reader reader){
        XmlConfigBuilder xmlConfigBuilder = new XmlConfigBuilder(reader);
        return build(xmlConfigBuilder.parse());
    }

    public SqlSessionFactory build(Configuration configuration){
        return new DefaultSqlSessionFactory(configuration);
    }
}
